package com.trade.wzj.service.xiang;

import com.trade.wzj.dao.xiang.ClientQuotaDao;
import com.trade.wzj.model.xiang.ClientQuota;

public class ClientQuotaimpl implements ClientQuotaService {
	private ClientQuotaDao mapper;

	public ClientQuotaDao getMapper() {
		return mapper;
	}

	public void setMapper(ClientQuotaDao mapper) {
		this.mapper = mapper;
	}

	/*
	 * (non-Javadoc)客户报价单添加
	 * 
	 * @see
	 * com.trade.wzj.service.xiang.ClientQuotaService#ClientQuotaAdd(com.trade.wzj.
	 * model.xiang.ClientQuota)
	 */
	@Override
	public int ClientQuotaAdd(ClientQuota clientquota) throws Exception {
		Integer ic = (int) (Math.random() * 9000) + 1000;
		
		if (clientquota.getClientInfoID() == null) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else if (clientquota.getPayID() == null) {
			try {
				throw new Exception("不能为空");
			} catch (Exception e) {
				e.printStackTrace();
			}
		
		} else {
			clientquota.setClientRandom(ic);
			int result = mapper.ClientQuotaAdd(clientquota);
			if (result > 0) {
				System.out.println("成功");
			}
		}
		return ic;
	}

	
	public ClientQuota findClientId(Integer id)throws Exception {
		ClientQuota client=null;
		try {
			client=mapper.findClientId(id);
		} catch (Exception e) {
			throw new Exception();
		}
		return client;
	}
}
